package week12;



import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class CopyBytesWithBuffer {
    public static void main(String[] args) throws IOException {
    	
    	BufferedInputStream bin = null;
    	BufferedOutputStream bout = null;
        

        try {
        	bin = new BufferedInputStream(new FileInputStream("src.txt"));
            bout = new BufferedOutputStream(new FileOutputStream("dst.txt"));
            
            byte[] temp = new byte[2048];
            while(bin.read(temp)!=-1){
            	bout.write(temp);
            }
            bout.flush();
            
        } finally {
            if (bin != null) {
                bin.close();
            }
            if (bout != null) {
                bout.close();
            }
        }
    }
}